package com.oolatina.fragments;

import java.util.ArrayList;

import newspackage.APIParser;
import newspackage.NewsBean;
import newspackage.WebServices;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.loopj.android.http.AsyncHttpResponseHandler;
import com.oolatina.R;
import com.oolatina.activity.OOLatinaApplication;
import com.oolatina.adapters.NewsAdapter;

public class NewsDetailFragment extends BaseFragment {
	ListView listView;
	OOLatinaApplication oolatina;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mView = inflater.inflate(R.layout.news_detail, null);

		checkWebServices();
		return mView;
	}

	public void checkWebServices() {

		WebServices.getNews(new AsyncHttpResponseHandler() {
			@Override
			public void onSuccess(String arg0) {

				ArrayList<NewsBean> newsList = APIParser.getNews(arg0);

				if (newsList.size() > 0) {
					NewsAdapter adapter2 = new NewsAdapter(getActivity(),
							newsList, getActivity());
					listView.setAdapter(adapter2);

				}

			}

		});
	}

	@Override
	public void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		checkWebServices();
	}

}